package com.tuozixuan.jol;

import org.openjdk.jol.info.ClassLayout;

public class EntityObject {
	
	private long id;
	
	private boolean flag;
	
	private byte byteVal;
	
	private char charVal;
	
	private short age;
	
	private int fansCount;
	
	private String name;
	
	private float pocketMoney;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public boolean isFlag() {
		return flag;
	}

	public void setFlag(boolean flag) {
		this.flag = flag;
	}

	public byte getByteVal() {
		return byteVal;
	}

	public void setByteVal(byte byteVal) {
		this.byteVal = byteVal;
	}

	public char getCharVal() {
		return charVal;
	}

	public void setCharVal(char charVal) {
		this.charVal = charVal;
	}

	public short getAge() {
		return age;
	}

	public void setAge(short age) {
		this.age = age;
	}

	public int getFansCount() {
		return fansCount;
	}

	public void setFansCount(int fansCount) {
		this.fansCount = fansCount;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public float getPocketMoney() {
		return pocketMoney;
	}

	public void setPocketMoney(float pocketMoney) {
		this.pocketMoney = pocketMoney;
	}

	public double getMoney() {
		return money;
	}

	public void setMoney(double money) {
		this.money = money;
	}

	private double money;

	public static void main(String[] args) {
		EntityObject entity = new EntityObject();
		entity.setId(820225435405205504L); // 8字节
		entity.setFlag(true); // 1字节
		byte byteVal = 1; 
		entity.setByteVal(byteVal); // 1字节
		entity.setCharVal('a'); // 2字节
		short age = 20;
		entity.setAge(age); // 2字节
		entity.setFansCount(34765); // 4字节
		entity.setPocketMoney(200.34f); // 4字节
		entity.setMoney(10000.34); // 8字节
		entity.setName("Alex"); // 4字节（对象引用）
		
		// 头信息-mark：8字节；头信息-class：4字节；实例数据：34字节；对象对齐：2字节；总共：48字节
		System.out.println(ClassLayout.parseInstance(new EntityObject()).toPrintable());
	}

}
